<meta charset="utf-8">
<?php


/*include_once('init.php');*/
	if(!empty($_POST)) {
	/*	print_r($_POST);die;*/
		/*session_start();*/
		
		
		/*	$path='';
		if (!empty($_FILES['url']['name'][0])) {
			$urllist=array();
			foreach ($_FILES['url']['name'] as $key => $value) {
				$urllist[$key]['name']=$_FILES['url']['name'][$key ];
				$urllist[$key]['cate_id']=$_FILES['url']['cata_id'][$key ];
				$urllist[$key]['tmp_name']=$_FILES['url']['tmp_name'][$key ];
				$urllist[$key]['error']=$_FILES['url']['error'][$key ];
				$urllist[$key]['size']=$_FILES['url']['size'][$key ];
				
			}
			foreach ($urllist as $key => $val) {
					$path= url($val);
			}
			/*print_r($urllist);die;*/

		
		/*};*/


			


		$where['username']=$_POST['username'];
		$where['password']=$_POST['password'];
		$where['role_id']=$_POST['role_id'];
		/*$url=$path;*/
		/*$text=$_POST['text'];
		$textarea=$_POST['textarea'];*/
		
		
		
			
		$row=add('admin',$where);
    
        if ($row>0) {
        	echo '<script>alert("添加成功");location.href="index.php?c=name&a=news&admin=1";</script>';

        }else{
        	echo '<script>alert("添加失败");history.go(-1);</script>';die;
        }
		

	}
		

		$id=!empty($_GET['id'])?$_GET['id']:'0';
	/*$sql = "select * from `admin` where `pid`='$id'";
	$result=mysqli_query($link,$sql);
	while ($arr=mysqli_fetch_assoc($result)) {
		$cate[]=$arr;
	}*/
	$data=gatselect('role');
		
	$a=gatselect('admin',"`id`=$id");


        if (!empty($_SERVER['HTTP_X_REQUESTED_WITH'])) {

        
        	

        	echo json_encode($cate);die;
        	
        }
	include( VIEW_PATH.$admin.'layst.html');

?>
